<template>
  <div>
    <el-tree
      :data="data"
      node-key="catId"
      :props="defaultProps"
      @node-click="nodeClick"
    >
    </el-tree>
  </div>
</template>

<script>
/* eslint-disable */
export default {
  data() {
    //页面效果;
    return {
      data: [],
      defaultProps: {
        children: "children",
        label: "name"
      }
    };
  },
  created() {
    this.getCategory();
  },
  methods: {
    nodeClick(data, node, component) {
      console.log("点击了我", data, node, component);
      this.$emit("nodeClick", data, node, component);
    },
    getCategory() {
      this.$http({
        url: this.$http.adornUrl("/product/category/listTree"),
        method: "get"
      }).then(({ data }) => {
        console.log("成功获取的类别数据：", data.page);
        this.data = data.page;
        // this.expandKeys = [3];
      });
    }
  }
};
</script>

<style></style>
